﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:library="using:SlideView.Library"
                    xmlns:primitives="using:SlideView.Library.Primitives"
                    xmlns:helpers="using:SlideView.Library.Helpers">

    <Style TargetType="library:SlideApplicationFrame">
        <Setter Property="Background"
                Value="Transparent" />
        <Setter Property="HorizontalContentAlignment"
                Value="Stretch" />
        <Setter Property="VerticalContentAlignment"
                Value="Stretch" />
        <Setter Property="HeaderTemplate">
            <Setter.Value>
                <DataTemplate>
                    <Grid Background="#48649F">
                        <TextBlock Margin="6,12"
                                   HorizontalAlignment="Center"
                                   VerticalAlignment="Center"
                                   FontSize="26"
                                   Text="{Binding}" />
                    </Grid>
                </DataTemplate>
            </Setter.Value>
        </Setter>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="library:SlideApplicationFrame">
                    <Grid Background="{TemplateBinding Background}"
                          x:Name="Root">
                        <Grid.Resources>
                            <Style TargetType="Button"
                                   x:Key="SideButtonStyle">
                                <Setter Property="Padding"
                                        Value="4" />
                                <Setter Property="Margin"
                                        Value="-6" />
                                <Setter Property="BorderThickness"
                                        Value="0" />
                            </Style>

                            <Storyboard x:Key="PageTransitionForward">
                                <DoubleAnimation Storyboard.TargetName="PreviousPageCache"
                                                 Storyboard.TargetProperty="Opacity"
                                                 To="0"
                                                 BeginTime="0:0:0.2"
                                                 Duration="0:0:0.2" />
                                <DoubleAnimation Storyboard.TargetName="PreviousPageCacheTransform"
                                                 Storyboard.TargetProperty="TranslateY"
                                                 From="0"
                                                 To="800"
                                                 Duration="0:0:0.3">
                                    <DoubleAnimation.EasingFunction>
                                        <QuadraticEase EasingMode="EaseOut" />
                                    </DoubleAnimation.EasingFunction>
                                </DoubleAnimation>
                                <DoubleAnimation Storyboard.TargetName="ClientAreaTransform"
                                                 Storyboard.TargetProperty="TranslateY"
                                                 From="-800"
                                                 To="0"
                                                 Duration="0:0:0.3">
                                    <DoubleAnimation.EasingFunction>
                                        <QuadraticEase EasingMode="EaseOut" />
                                    </DoubleAnimation.EasingFunction>
                                </DoubleAnimation>
                            </Storyboard>

                            <Storyboard x:Key="PageTransitionBackward">
                                <DoubleAnimation Storyboard.TargetName="PreviousPageCache"
                                                 Storyboard.TargetProperty="Opacity"
                                                 To="0"
                                                 BeginTime="0:0:0.2"
                                                 Duration="0:0:0.2" />
                                <DoubleAnimation Storyboard.TargetName="PreviousPageCacheTransform"
                                                 Storyboard.TargetProperty="TranslateY"
                                                 From="0"
                                                 To="-800"
                                                 Duration="0:0:0.3">
                                    <DoubleAnimation.EasingFunction>
                                        <QuadraticEase EasingMode="EaseOut" />
                                    </DoubleAnimation.EasingFunction>
                                </DoubleAnimation>
                                <DoubleAnimation Storyboard.TargetName="ClientAreaTransform"
                                                 Storyboard.TargetProperty="TranslateY"
                                                 From="800"
                                                 To="0"
                                                 Duration="0:0:0.3">
                                    <DoubleAnimation.EasingFunction>
                                        <QuadraticEase EasingMode="EaseOut" />
                                    </DoubleAnimation.EasingFunction>
                                </DoubleAnimation>
                            </Storyboard>
                        </Grid.Resources>

                        <library:SlideView x:Name="MainPanel"
                                            SelectedIndex="1">

                            <Grid Background="White"
                                  primitives:SlideViewPanel.PanelIndex="1">
                                <Grid.RowDefinitions>
                                    <RowDefinition Height="Auto" />
                                    <RowDefinition />
                                </Grid.RowDefinitions>

                                <Border Grid.Row="1"
                                        Background="Transparent">
                                    <Border.RenderTransform>
                                        <CompositeTransform x:Name="PreviousPageCacheTransform" />
                                    </Border.RenderTransform>
                                    <Image x:Name="PreviousPageCache"
                                           Margin="{TemplateBinding Padding}" />
                                </Border>

                                <Border x:Name="ClientArea"
                                        Grid.Row="1"
                                        Background="Transparent">
                                    <Border.RenderTransform>
                                        <CompositeTransform x:Name="ClientAreaTransform" />
                                    </Border.RenderTransform>
                                    <ContentPresenter ContentTemplate="{TemplateBinding ContentTemplate}"
                                                      Content="{TemplateBinding Content}"
                                                      HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                                      Margin="{TemplateBinding Padding}"
                                                      VerticalAlignment="{TemplateBinding VerticalContentAlignment}" />
                                </Border>

                                <Grid x:Name="Header"
                                      Grid.Row="0">
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="Auto" />
                                        <ColumnDefinition />
                                        <ColumnDefinition Width="Auto" />
                                    </Grid.ColumnDefinitions>

                                    <ContentPresenter Content="{TemplateBinding Header}"
                                                      ContentTemplate="{TemplateBinding HeaderTemplate}"
                                                      Grid.ColumnSpan="3" />

                                    <Button Style="{StaticResource SideButtonStyle}"
                                            x:Name="LeftPanelButton">
                                        <Image Source="/Assets/menu.png" />
                                    </Button>

                                    <Button Style="{StaticResource SideButtonStyle}"
                                            Grid.Column="2"
                                            x:Name="RightPanelButton">
                                        <Image Source="/Assets/menu.png" />
                                    </Button>
                                </Grid>

                            </Grid>

                            <Grid Width="{TemplateBinding SidePanelWidth}"
                                  primitives:SlideViewPanel.PanelIndex="0">
                                <ContentPresenter Content="{TemplateBinding LeftContent}" />
                            </Grid>


                            <Grid Width="{TemplateBinding SidePanelWidth}"
                                  primitives:SlideViewPanel.PanelIndex="2">
                                <ContentPresenter Content="{TemplateBinding RightContent}" />
                            </Grid>

                        </library:SlideView>

                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style TargetType="library:SlideView">
        <Setter Property="Background"
                Value="Transparent" />
        <Setter Property="ItemsPanel">
            <Setter.Value>
                <ItemsPanelTemplate>
                    <primitives:SlideViewPanel />
                </ItemsPanelTemplate>
            </Setter.Value>
        </Setter>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="library:SlideView">
                    <Border Background="{TemplateBinding Background}">
                        <Grid>
                            <Grid.RenderTransform>
                                <TranslateTransform x:Name="SlidingTransform" />
                            </Grid.RenderTransform>
                            <ItemsPresenter x:Name="ItemsList" />
                        </Grid>
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style TargetType="library:AutoHideBar">
        <Setter Property="Background"
                Value="Linen" />
        <Setter Property="HorizontalContentAlignment"
                Value="Stretch" />
        <Setter Property="VerticalContentAlignment"
                Value="Stretch" />
        <Setter Property="VerticalAlignment"
                Value="Top" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="ContentControl">
                    <Grid helpers:ClipToBounds.ClipToBounds="True">
                        <VisualStateManager.VisualStateGroups>
                            <VisualStateGroup x:Name="CommonStates">
                                <VisualState x:Name="Show">
                                    <Storyboard>
                                        <DoubleAnimation Storyboard.TargetName="RootTransform"
                                                         Storyboard.TargetProperty="TranslateY"
                                                         To="0"
                                                         Duration="0:0:0.5">
                                            <DoubleAnimation.EasingFunction>
                                                <QuadraticEase EasingMode="EaseOut" />
                                            </DoubleAnimation.EasingFunction>
                                        </DoubleAnimation>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="Root"
                                                                       Storyboard.TargetProperty="(UIElement.Visibility)">
                                            <DiscreteObjectKeyFrame KeyTime="0:0:0">
                                                <DiscreteObjectKeyFrame.Value>
                                                    <Visibility>Visible</Visibility>
                                                </DiscreteObjectKeyFrame.Value>
                                            </DiscreteObjectKeyFrame>
                                        </ObjectAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="Hide">
                                    <Storyboard>
                                        <DoubleAnimation Storyboard.TargetName="RootTransform"
                                                         Storyboard.TargetProperty="TranslateY"
                                                         To="-100"
                                                         Duration="0:0:0.5">
                                            <DoubleAnimation.EasingFunction>
                                                <QuadraticEase EasingMode="EaseOut" />
                                            </DoubleAnimation.EasingFunction>
                                        </DoubleAnimation>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="Root"
                                                                       Storyboard.TargetProperty="(UIElement.Visibility)">
                                            <DiscreteObjectKeyFrame KeyTime="0:0:5">
                                                <DiscreteObjectKeyFrame.Value>
                                                    <Visibility>Collapsed</Visibility>
                                                </DiscreteObjectKeyFrame.Value>
                                            </DiscreteObjectKeyFrame>
                                        </ObjectAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                            </VisualStateGroup>
                        </VisualStateManager.VisualStateGroups>

                        <Grid Background="{TemplateBinding Background}"
                              x:Name="Root">
                            <Grid.RenderTransform>
                                <CompositeTransform x:Name="RootTransform" />
                            </Grid.RenderTransform>

                            <ContentPresenter Content="{TemplateBinding Content}"
                                              ContentTemplate="{TemplateBinding ContentTemplate}"
                                              Margin="{TemplateBinding Padding}"
                                              HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                              VerticalAlignment="{TemplateBinding VerticalContentAlignment}" />
                        </Grid>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

</ResourceDictionary>
